package com.csnf.dao.impl;

import com.csnf.dao.IClazzDao;
import com.csnf.entity.Clazz;
import com.csnf.entity.Student;
import com.csnf.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;

public class ClazzDaoImpl implements IClazzDao {
    @Override
    public List<Clazz> findAll() throws IOException {
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        List<Clazz> clazzList = sqlSession.selectList("com.csnf.dao.IClazzDao.findAll");
        sqlSession.close();
        return clazzList;
    }

    @Override
    public Clazz findById(Integer id) throws IOException {
        try (SqlSession sqlSession = SqlSessionUtil.getSqlSession()) {
            IClazzDao iClazzDao = sqlSession.getMapper(IClazzDao.class);
            return iClazzDao.findById(id);
        }
    }
}
